from apscheduler.schedulers.blocking import BlockingScheduler
from loguru import logger

from task.estate_task import LianjiaTask


def start_lianjia_task():
    url_list = ["https://wh.lianjia.com/fangjia/priceTrend?region=city&region_id=420100"]
    LianjiaTask().start(url_list)


def start_schedule():
    # 创建调度器：BlockingScheduler
    scheduler = BlockingScheduler()

    # 添加任务,时间间隔2S
    scheduler.add_job(start_lianjia_task, trigger='cron', hour='1', id='lianjia_task')

    scheduler.start()
    logger.info("scheduler start")
